//DOM结构加载完成
$(function(){
    //初始化推广页面内容
    EasyAjax.ajax_Get_Json({
        url: "article/queryArticle.json",
        data: {editTacticsUid:"010bbf9d-29be-43f1-8917-f66bff319d90"}
    },
    function (data) {
        data.data.api_host = api_host;
        var $spread = $("#spreadTpl").render(data.data);
        $("#spread").html($spread);
        //初始化老师信息
        EasyAjax.ajax_Get_Json({
            url: "teacher/getTeacherList.json"
        },
        function (data) {
            $.each(data.data,function (index,ele) {
                this.api_host = api_host;
            });
            var $teacher = $("#teacherTpl").render(data.data);
            $("#teacherBox").html($teacher);
            $("#wechatNum").html(data.data[0].age);
        });
    });
    //分页
    function page(data) {
        $.each(data.data,function (index,ele) {
            this.api_host = api_host;
        });
        var nums = 10;
        var pages = Math.ceil(data.data.length / nums);
        var pageIndex = 1;
        var render = function (curr) {
            var last = curr * nums - 1,
                review = new Array();
            last = last >= data.data.length ? (data.data.length - 1) : last;
            for (var i = (curr * nums - nums); i <= last; i++) {
                review.push(data.data[i]);
            }
            var $review = $("#reviewTpl").render(review);
            return $review;
        };
        $("#page").on("click",function () {
            if (pageIndex <= pages){
                $("#comment-content").append(render(pageIndex));
                pageIndex++;
            }
        });
        $("#page").click();
    }
    //初始化评论信息
    EasyAjax.ajax_Get_Json({
        url: "review/getReviewList.json"
    },
    function (data) {
        page(data);
    });
});